home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1931 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: softsite.co.at!wsog
  2. Date: 17 Jan 1996 09:11:00 +0200
  3. From: wsog@softsite.co.at (Walter Sommergruber)
  4. Newsgroups: comp.lang.c
  5. Message-ID: <613O-oOMnTB@softsite.co.at>
  6. References: <4d9k6fINNnja@faatcrl.faa.gov> <4dc6kq$dja@gryphon.phoenix.net>
  7.     <DL9GIA.4y1@eskimo.com>
  8. Subject: Re: Checking for a file => Does it exist (Help)
  9. X-Newsreader: XP v3.02
  10. X-Charset: ISO-8859-1
  11. Organization: Sommergruber Software & Dienstleistungen
  12.  
  13. mAg  (mag@eskimo.com) wrote on 16.01.96
  14. about "Re: Checking for a file => Does it exist (Help)":
  15.  
  16. > In article <4dc6kq$dja@gryphon.phoenix.net> (Mon, 15 Jan 1996 01:00:31 GMT),
  17. > brucew@phoenix.net says :
  18. > >afrawert@faatcrl.faa.gov (Alan Frawert) wrote:
  19. > >>I'm having a problem just checking to see if a file
  20. > >>exists. Does anyone have a simple piece of code that I can use?
  21. > >
  22. > >Well, you could try to open it then close it:
  23. > Just a little smarter(?) version :-)
  24. >
  25. > int file_exist(char *fname)
  26. > {
  27. > FILE *fp;
  28. > if (fp = fopen(fname,"r"))
  29. >   {
  30. >   fclose(fp);
  31. >   return(1);
  32. >   }
  33. > return (0);
  34. > }
  35.  
  36. What is if the file exists but you have not the right to read it ?
  37. The fopen would fail but the file exists.
  38. I know the non-portable ways with fstat (DOS, Unix) but is there
  39. a portable way to tell if the file exists ?
  40.  
  41. ---                                     Take a look at ...
  42. Walter Sommergruber                                    The Software Site
  43. email: wsog@softsite.co.at           http://www.softsite.co.at/softsite/
  44.